package com.sky.yipinyoufujava.mapper;

import com.sky.yipinyoufujava.pojo.from.GetSingleOrderGoodsFrom;
import com.sky.yipinyoufujava.pojo.from.OrderForm;
import com.sky.yipinyoufujava.pojo.goods.Goods;
import com.sky.yipinyoufujava.pojo.order.CreateOrder;
import com.sky.yipinyoufujava.pojo.order.Order;
import com.sky.yipinyoufujava.pojo.order.OrderStatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
    List<Order> getOrder(OrderForm orderForm);


    @Select("SELECT * FROM `OrderGoods` og JOIN `Goods` g ON og.goodsId = g.id WHERE og.orderId = #{orderId};")
    List<Goods> getSingleOrderGoods(GetSingleOrderGoodsFrom orderId);

    Order getSingleOrderInfo(GetSingleOrderGoodsFrom orderId);


    void createTemporaryOrder(CreateOrder createOrder);

    void createOfficiallyOrder(Order order);
    @Update("UPDATE `Order` SET `orderStatus` = #{status}, `orderStatusTitle` = #{statusName} WHERE `orderId` = #{orderId};")
    void updateOrderStatus(OrderStatus orderStatus);

    void insertOrderGoodsList(@Param("orderNumber") String orderNumber,@Param("orderGoodsId") List<String> orderGoodsId);

    void updateOrderInfo(Order order);



}
